<div class="list-your-property-form">
    <h2 class="page-header"><?= $title; ?></h2>
    <div class="content">
        <div class="row">
            <div class="span8">
                <p></p>
            </div><!-- /.span8 -->
        </div><!-- /.row -->

        <?php
        $form = $this->beginWidget('CActiveForm', array(
            'id' => 'getscores-form',
            'enableAjaxValidation' => false,
            'clientOptions' => array(
                'validateOnSubmit' => true,
            ),
            'htmlOptions' => array(
                'class' => 'contact-form',
                'enctype' => 'multipart/form-data'
            ),
        ));
        ?>

        <?php if ($model->getErrors()) { ?> 
            <div class="alert alert-error">
                <button type="button" class="close" data-dismiss="alert">×</button>
                <?php echo $form->errorSummary(array($model)); ?>
            </div>
        <?php }; ?>

        <div class="row">
            <div class="span3">
                <?php $field = 'city_id'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputContactName">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                        <span class="form-required" title="This field is required.">*</span>
                    </label>
                    <div class="controls">
                        <?php echo $form->dropDownList($model, $field, CHtml::listData(City::model()->getActiveCity(), 'id', 'name'), array('empty' => 'Выберите ...')); ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->
            </div><!-- /.span3 -->
            <div class="span5">
                <?php $field = 'street'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputContactName">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                        <span class="form-required" title="This field is required.">*</span>
                    </label>
                    <div class="controls">
                        <?php
                        echo $form->textField($model, $field, array(
                            'placeholder' => 'ул.Мира',
                        ))
                        ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->
            </div><!-- /.span5 -->
            <div class="span1">
                <?php $field = 'home'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputContactName">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                        <span class="form-required" title="This field is required.">*</span>
                    </label>
                    <div class="controls">
                        <?php
                        echo $form->textField($model, $field, array(
                            'placeholder' => ' 43Б',
                        ))
                        ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->
            </div><!-- /.span1 -->
            <div class="span1">
                <?php $field = 'korp'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputContactName">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                    </label>
                    <div class="controls">
                        <?php
                        echo $form->textField($model, $field, array(
                            'placeholder' => ' 2',
                        ))
                        ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->
            </div><!-- /.span1 -->
        </div><!-- /.row -->

        <div class="row">
            <div class="span3">
                <?php $field = 'type_id'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputPropertyLocation">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                        <span class="form-required" title="This field is required.">*</span>
                    </label>
                    <div class="controls">
                        <?= $form->dropDownList($model, $field, Flat::getTypeFlat(), array('empty' => 'Выберите ...')); ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->
            </div><!-- /.span3 -->
            <div class="span3">
                <?php $field = 'repair_id'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputPropertyLocation">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                        <span class="form-required" title="This field is required.">*</span>
                    </label>
                    <div class="controls">
                        <?= $form->dropDownList($model, $field, Flat::getRepair(), array('empty' => 'Выберите ...')); ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->
            </div><!-- /.span3 -->
            <div class="span2">
                <?php $field = 'guests'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputPropertyContractType">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                        <span class="form-required" title="This field is required.">*</span>
                    </label>
                    <div class="controls">
                        <?= $form->dropDownList($model, $field, Flat::getSleeper(), array('empty' => 'Выберите ...')); ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->
            </div><!-- /.span2 -->
            <div class="span2">
                <?php $field = 'sleeper'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputPropertyBedrooms">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                        <span class="form-required" title="This field is required.">*</span>
                    </label>
                    <div class="controls">
                        <?php
                        echo $form->textField($model, $field, array(
                            'placeholder' => '2+2+1',
                        ))
                        ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->
            </div><!-- /.span2 -->
            <div class="span2">
                <?php $field = 'price'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputPropertyBedrooms">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                        <span class="form-required" title="This field is required.">*</span>
                    </label>
                    <div class="controls">
                        <?php
                        echo $form->textField($model, $field, array(
                            'placeholder' => ' 300',
                        ))
                        ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->
            </div><!-- /.span2 -->


            <div class="span12">
                <?php $field = 'comfort'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputContactMessage">
                        Комфорт:
                        <span class="form-required" title="This field is required.">*</span>
                    </label>
                    <div class="controls">
                        <div class="row">
                            <?php foreach ($comfort as $item) { ?>
                                <div class="span3">
                                    <?php 
                                    $checked = false;
                                    foreach($model->comforts as $comfort){
                                        if($comfort->id == $item->id){
                                            $checked = true;
                                        }
                                    }
                                    ?>
                                    <?php echo $form->checkBox($model, $field . '[]', array(
                                        'value' => $item->id,
                                        'style' => 'margin: 0px 0px 0px 25px',
                                        'checked' => $checked ? 'checked' : '',
                                        )) . " " . $item->title; ?>
                                </div><!-- /.span8 -->
                            <?php } ?>
                        </div><!-- /.row -->
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->
            </div><!-- /.span12 -->


            <div class="span12">
                <?php $field = 'description'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputContactMessage">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                        <span class="form-required" title="This field is required.">*</span>
                    </label>

                    <div class="controls">
                        <?php echo $form->textArea($model, $field, array('placeholder' => 'Введите описание')); ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->
            </div><!-- /.span12 -->

            <div class="span6">
                <?php $field = 'infrastructure'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputContactMessage">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                        
                    </label>

                    <div class="controls">
                        <?php echo $form->textArea($model, $field, array('placeholder' => 'Что находится рядом')); ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->
            </div><!-- /.span4 -->

            <div class="span6">
                <?php $field = 'furniture'; ?>
                <div class="control-group">
                    <label class="control-label" for="inputContactMessage">
                        <?php echo strip_tags($form->label($model, $field)); ?>
                        
                    </label>

                    <div class="controls">
                        <?php echo $form->textArea($model, $field, array('placeholder' => 'Перечислите всю мебель через запятую')); ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->
            </div><!-- /.span4 -->


            <?php for ($i = 0; $i < 8; $i++) { ?>
                <?php $field = 'img' . $i; ?>
                <div class="span3" style="padding-bottom:10px; padding-top:10px;">
                    <div class="control-group">
                        <label class="control-label pagination-centered" for="inputContactMessage">
                            <?php echo strip_tags($form->label($model, $field)); ?>
                            <?php if(!$i){ ?>
                               <span class="form-required" title="This field is required.">*</span> 
                            <?php } ?>
                        </label>
                        <div class="fileupload fileupload-new" data-provides="fileupload">
                            <div class="fileupload-preview thumbnail" style="width: 260px; height: 195px;">
                                <?php if (!empty($model->{$field})) { ?>
                                    <?=ImageResizer::getThumb($model->{$field} , 'data/imgs/flat/'.$model->id.'/' , $model->{$field}, 260 , 195 )?>
                                <?php } else { ?>
                                    <img src="/data/imgs/flat/noimg.gif"/>
                                <?php } ?>
                            </div>
                            <div class="pagination-centered">
                                <span class="btn btn-file btn-primary">
                                    <span class="fileupload-new">Выбрать фото</span>
                                    <span class="fileupload-exists">Изменить</span>
                                    <?php echo CHtml::activeFileField($model, $field); ?>
                                </span>
                                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Удалить</a>
                            </div>
                        </div> 
                    </div>
                </div><!-- /.span4 -->
            <?php } ?>

            <div class="span12">
                <div class="control-group">
                    <div class="controls pagination-centered">
                        <?php echo CHtml::submitButton($button, array('class' => 'btn btn-primary btn-large list-your-property arrow-right')); ?>
                    </div><!-- /.controls -->
                </div><!-- /.control-group -->
            </div><!-- /.span12 -->

        </div><!-- /.row -->
        <?php $this->endWidget(); ?>
    </div><!-- /.content -->
</div>